package experiment4.knapsack;

import java.util.Comparator;

class Goods implements Comparator<Goods> {
    int weight;
    int value;
    float weightValue;

    Goods(int weight, int value) {
        this.value = value;
        this.weight = weight;
        this.weightValue = ((float) value / weight);
    }

    Goods() {
    }

    @Override
    public int compare(Goods o1, Goods o2) {
        return Double.compare(o2.weightValue, o1.weightValue);
    }

    @Override
    public String toString() {
        return "{weight=" + weight +
                ", value=" + value +
                ", weightValue=" + weightValue+"}";
    }
}
